/*
 * sensor.h
 *
 *  Created on: 13-gen-2009
 *      Author: fabrizio
 */
/*

 Copyright (c) 2008-2009 Fabrizio Pistonesi

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

 */
#ifndef SENSOR_H_
#define SENSOR_H_

#include<string>
using namespace std;

#include<irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

struct Action
{
  s32 Target;
  int Effect; //0 Fade; 1 Wipe; 2 Rotate;
  float Factor;
  int Duration;
  int Cursor;
  std::string Message;
};

class Sensor
{
public:
  Sensor(IrrlichtDevice* device, f32 width, f32 height, f32 az, f32 el);
  Sensor(IrrlichtDevice* device, IGUIElement *parent, s32 width, s32 height, s32 x, s32 y);
  void setAction(s32 target, int effect, float factor, int duration, int cursor, std::string message, bool enable = true);
  void move(f32 az, f32 el, f32 width = -1, f32 height = -1);
  void setEnable(bool enable);
  bool isEnable();
  bool isVisible();
  void setVisible(bool visible);
  void serialize(IAttributes *attributes);

  IrrlichtDevice* Device;
  ISceneNode *SensorRotation, *SensorCube;
  IGUIImage *SensorGUI;
  bool Enable, Visible, Selected;
  f32 Width, Height, Azimuth, Elevation;
  s32 X,Y,W,H;

  Action DefAction;

  u32 Time;
  bool Repeat;

  //void check(const SEvent &event);
  void check();
  // Variables containing the name of the LUA function to call from C++
  std::string OnMouseIn, OnMouseOut, OnMouseDown, OnMouseUp, OnTime;

  virtual
  ~Sensor();
};

#endif /* SENSOR_H_ */
